<?php

namespace App\Libraries\Entities;

trait HasEditEnable
{
    protected $EditEnableFlag = false;

    public function useEditEnable()
    {
        return $this->EditEnableFlag;
    }

    public function setEditEnable()
    {
        $message = '';
        if (!is_null(static::EDIT_ENABLE) && !$this->isDirty(static::EDIT_ENABLE)) {
            if ($this->{static::EDIT_ENABLE}) {
                $message = $this->EditEnable();
            } else {
                $message = $this->EditDisable();
            }
        }

        return $message;
    }

    protected function EditEnable()
    {
        $this->{static::EDIT_ENABLE} = 1;

        return $message = '编辑启用';
    }

    protected function EditDisable()
    {
        $this->{static::EDIT_ENABLE} = 0;

        return $message = '编辑禁用';
    }
}
